let express = require('express');

let app = express();

app.use('/', (req, res, next) => {//中间函数
    //req请求对象
    //res响应对象
    //继续执行后面的代码
    let { token } = req.query;
    if (token === 'abc123') {
        next();
    } else {
        res.send('缺少token参数');
    }
    
});

// ues 中间件
app.use('/user', (req, res, next) => {
    let { money } = req.query;
    if (money > 1000000) {
        req.query.money = 1500000;
        next();
    }else{
        res.send('资金必须大于10w')
    }
})

app.get('/a', (req, res, next) => {
    let { abc } = req.query;
    if (abc === '123') {
        next();
    } else {
        res.send('缺少abc参数');
    }
}), (req, res) => {
    res.sedn('get /a');
    };


app.get('/b', (req, res) => {
    res.send('get /b');
});
app.get('/c', (req, res) => {
    res.send('get /c');
});

app.post('/user/login', (req, res) => {
    res.send('post/user/login');
});

app.post('/user/register', (req, res) => {
    res.send('post/user/register');
});

app.listen(3004, () => {
    console.log('-------------ok-------------------');
})